﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
''' <summary>
''' 用于储存计算结果的类
''' </summary>
''' <remarks></remarks>
<Serializable()> Public Class NameAndData
    Private m_Name As String

    
    Private m_GridCon As New GridCon   '用于储存网格中的浓度数据
    Private m_DiscCon(-1) As ResultCon '储存关心点浓度最大的数据

    Private m_GridDEPOS As New GridDepos  '用于储存网格中的总沉积度数据
    Private m_DiscDEPOS(-1) As ResultDEPOS '储存关心点总沉积最大的数据

    
    Private m_GridDDEP As New GridDepos '用于储存网格中的浓度数据
    Private m_DiscDDEP(-1) As ResultDEPOS '储存关心点浓度最大的数据

    Private m_GridWDEP As New GridDepos '用于储存网格中的浓度数据
    Private m_DiscWDEP(-1) As ResultDEPOS '储存关心点浓度最大的数据

    Private m_SubGridCon(-1) As GridCon  '用于储存嵌套网格中的浓度数据
    Private m_SubGridDEPOS(-1) As GridDepos '用于储存嵌套网格中的总沉积度数据
    Private m_SubGridDDEP(-1) As GridDepos '用于储存嵌套网格中的浓度数据
    Private m_SubGridWDEP(-1) As GridDepos '用于储存嵌套网格中的浓度数据

    ''' <summary>
    ''' 计算结果的文件的名称
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property Name() As String
        Get
            Return Me.m_Name
        End Get
        Set(ByVal value As String)
            Me.m_Name = value
        End Set
    End Property

    
    ''' <summary>
    ''' 储存网格中的数据。按行、列储存
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridCon() As GridCon  '用于储存网格中的数据
        Get
            Return Me.m_GridCon
        End Get
        Set(ByVal value As GridCon)
            Me.m_GridCon = value
        End Set
    End Property
    
    ''' <summary>
    ''' 储存关心点的数据。表示多个关心点，每个关心点都有各自的数据。
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscCon() As ResultCon()
        Get
            Return Me.m_DiscCon
        End Get
        Set(ByVal value As ResultCon())
            Me.m_DiscCon = value
        End Set
    End Property
    
    ''' <summary>
    ''' 用于储存网格中的总沉积度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridDEPOS() As GridDepos
        Get
            Return m_GridDEPOS
        End Get
        Set(ByVal value As GridDepos)
            m_GridDEPOS = value
        End Set
    End Property
   
    ''' <summary>
    ''' 储存关心点总沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscDEPOS() As ResultDEPOS() '
        Get
            Return m_DiscDEPOS
        End Get
        Set(ByVal value As ResultDEPOS())
            m_DiscDEPOS = value
        End Set
    End Property
    
    ''' <summary>
    ''' 用于储存网格中的干沉积数据
    ''' </summary>
    ''' <remarks></remarks>
    Property GridDDEP() As GridDepos
        Get
            Return m_GridDDEP
        End Get
        Set(ByVal value As GridDepos)
            m_GridDDEP = value
        End Set
    End Property
   
    ''' <summary>
    ''' 储存关心点干沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscDDEP() As ResultDEPOS() '
        Get
            Return m_DiscDDEP
        End Get
        Set(ByVal value As ResultDEPOS())
            m_DiscDDEP = value
        End Set
    End Property

    ''' <summary>
    ''' 用于储存网格中的湿沉积数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GridWDEP() As GridDepos  '
        Get
            Return m_GridWDEP
        End Get
        Set(ByVal value As GridDepos)
            m_GridWDEP = value
        End Set
    End Property
    
    ''' <summary>
    ''' 储存关心点湿沉积最大的数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property DiscWDEP() As ResultDEPOS() '
        Get
            Return m_DiscWDEP
        End Get
        Set(ByVal value As ResultDEPOS())
            m_DiscWDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridCon() As GridCon()
        Get
            Return Me.m_SubGridCon
        End Get
        Set(ByVal value As GridCon())
            Me.m_SubGridCon = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的总沉积度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridDEPOS() As GridDepos()
        Get
            Return Me.m_SubGridDEPOS
        End Get
        Set(ByVal value As GridDepos())
            Me.m_SubGridDEPOS = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridDDEP() As GridDepos()
        Get
            Return Me.m_SubGridDDEP
        End Get
        Set(ByVal value As GridDepos())
            Me.m_SubGridDDEP = value
        End Set
    End Property
    ''' <summary>
    ''' 用于储存嵌套网格中的浓度数据
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property SubGridWDEP() As GridDepos()
        Get
            Return Me.m_SubGridWDEP
        End Get
        Set(ByVal value As GridDepos())
            Me.m_SubGridWDEP = value
        End Set
    End Property

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的数据
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名的字符串数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetDataFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        If GetGridDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, version) = False Then
            Return False
        End If
        If GetDiscDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, version) = False Then
            Return False
        End If
        If GetGridMaxDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strAerageTime, strHIGHEST, strGroup, version) = False Then
            Return False
        End If
        Return True
    End Function
    ''' <summary>
    ''' 获取网格点前n大给定短期间的浓度分布
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名内容的一维数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetGridDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean

        Dim AGridData(,) As ResultCon = GetCustomGridCon(strAERMODOUT, Receptor.GridCart.Ynum, Receptor.GridCart.Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.GridCart.Netid, version)
        If AGridData IsNot Nothing Then
            Me.m_GridCon.GridCon = AGridData
            '根据网格数据求最大值和最小值
            Me.m_GridCon.CalMaxAndMinValue(Receptor.GridCart.Xnum, Receptor.GridCart.Ynum)
        End If
        If IsDep Then
            Try
                Dim AGridDep(,) As ResultDEPOS = GetCustomGridDep(strAERMODOUT, Receptor.GridCart.Ynum, Receptor.GridCart.Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.GridCart.Netid, "TOTAL DEPOSITION", version)
                If AGridDep IsNot Nothing Then
                    Me.m_GridDEPOS.GridDEPOS = AGridDep
                    '根据网格数据求最大值和最小值
                    Me.m_GridDEPOS.CalMaxAndMinValue(Receptor.GridCart.Xnum, Receptor.GridCart.Ynum)
                End If
                AGridDep = GetCustomGridDep(strAERMODOUT, Receptor.GridCart.Ynum, Receptor.GridCart.Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.GridCart.Netid, "DRY DEPOSITION", version)
                If AGridDep IsNot Nothing Then
                    Me.m_GridDDEP.GridDEPOS = AGridDep
                    '根据网格数据求最大值和最小值
                    Me.m_GridDDEP.CalMaxAndMinValue(Receptor.GridCart.Xnum, Receptor.GridCart.Ynum)
                End If
                AGridDep = GetCustomGridDep(strAERMODOUT, Receptor.GridCart.Ynum, Receptor.GridCart.Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.GridCart.Netid, "WET DEPOSITION", version)
                If AGridDep IsNot Nothing Then
                    Me.m_GridWDEP.GridDEPOS = AGridDep
                    '根据网格数据求最大值和最小值
                    Me.m_GridWDEP.CalMaxAndMinValue(Receptor.GridCart.Xnum, Receptor.GridCart.Ynum)
                End If

            Catch ex As Exception

            End Try

        End If




        ReDim Me.m_SubGridCon(Receptor.SubGridCart.Length - 1)
        For iSub As Integer = 0 To Receptor.SubGridCart.Length - 1
            Dim BGridCon(,) As ResultCon = GetCustomGridCon(strAERMODOUT, Receptor.SubGridCart(iSub).Ynum, Receptor.SubGridCart(iSub).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(iSub).Netid, version)
            If BGridCon IsNot Nothing Then
                Me.m_SubGridCon(iSub) = New GridCon
                Me.m_SubGridCon(iSub).GridCon = BGridCon
                '根据网格数据求最大值和最小值
                Me.m_SubGridCon(iSub).CalMaxAndMinValue(Receptor.SubGridCart(iSub).Xnum, Receptor.SubGridCart(iSub).Ynum)
            End If
            If IsDep Then
                Try
                    Dim AGridDep(,) As ResultDEPOS = GetCustomGridDep(strAERMODOUT, Receptor.SubGridCart(iSub).Ynum, Receptor.SubGridCart(iSub).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(iSub).Netid, "TOTAL DEPOSITION", version)
                    If AGridDep IsNot Nothing Then
                        Me.m_SubGridDEPOS(iSub) = New GridDepos
                        Me.m_SubGridDEPOS(iSub).GridDEPOS = AGridDep
                        '根据网格数据求最大值和最小值
                        Me.m_SubGridDEPOS(iSub).CalMaxAndMinValue(Receptor.SubGridCart(iSub).Xnum, Receptor.SubGridCart(iSub).Ynum)
                    End If
                    AGridDep = GetCustomGridDep(strAERMODOUT, Receptor.SubGridCart(iSub).Ynum, Receptor.SubGridCart(iSub).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(iSub).Netid, "DRY DEPOSITION", version)
                    If AGridDep IsNot Nothing Then
                        Me.m_SubGridDDEP(iSub) = New GridDepos
                        Me.m_SubGridDDEP(iSub).GridDEPOS = AGridDep
                        '根据网格数据求最大值和最小值
                        Me.m_SubGridDDEP(iSub).CalMaxAndMinValue(Receptor.SubGridCart(iSub).Xnum, Receptor.SubGridCart(iSub).Ynum)
                    End If
                    AGridDep = GetCustomGridDep(strAERMODOUT, Receptor.SubGridCart(iSub).Ynum, Receptor.SubGridCart(iSub).Xnum, IsDep, strAerageTime, strHIGHEST, strGroup, GroupSourceCount, Receptor.SubGridCart(iSub).Netid, "WET DEPOSITION", version)
                    If AGridDep IsNot Nothing Then
                        Me.m_SubGridWDEP(iSub) = New GridDepos
                        Me.m_SubGridWDEP(iSub).GridDEPOS = AGridDep
                        '根据网格数据求最大值和最小值
                        Me.m_SubGridWDEP(iSub).CalMaxAndMinValue(Receptor.SubGridCart(iSub).Xnum, Receptor.SubGridCart(iSub).Ynum)
                    End If

                Catch ex As Exception

                End Try

            End If

        Next
        'ReDim Me.m_GridCon(Receptor.GridCart.Ynum - 1, Receptor.GridCart.Xnum - 1)
        'Dim strLine As String = "" '读取一行
        'Dim nCol As Integer = 0 '用于记列数
        'Dim RowPage As Integer = 0 '用于标记行的页数
        'Dim ColPage As Integer = 0 '用于标记列的页数
        'For nAllString As Integer = 0 To strAERMODOUT.Length - 1
        '    strLine = strAERMODOUT(nAllString) '读取一行
        '    If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
        '        '开始计数
        '        nAllString += 3 '
        '        If GroupSourceCount > 19 Then
        '            nAllString += 2
        '        ElseIf GroupSourceCount > 7 Then
        '            nAllString += 1
        '        End If
        '        Dim strLineLine4 As String = strAERMODOUT(nAllString)
        '        If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
        '            nAllString += 7 '
        '            '开始读取网格数据
        '            Dim strDate As String
        '            For i As Integer = RowPage * 40 To RowPage * 40 + 39
        '                nAllString += 1
        '                strDate = strAERMODOUT(nAllString)
        '                For j As Integer = ColPage * 5 To ColPage * 5 + 4
        '                    If strDate.Substring(11 + nCol * 24, 13) = "*************" Then
        '                        MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
        '                        Return False
        '                    End If
        '                    Me.m_GridCon(i, j).con = strDate.Substring(11 + nCol * 24, 13)
        '                    Me.m_GridCon(i, j).dateD = strDate.Substring(26 + nCol * 24, 8)

        '                    If j >= Receptor.GridCart.Xnum - 1 Then
        '                        Exit For
        '                    End If
        '                    nCol += 1
        '                Next
        '                nCol = 0
        '                If i >= Receptor.GridCart.Ynum - 1 Then
        '                    ColPage += 1
        '                    RowPage = -1
        '                    Exit For
        '                End If
        '            Next
        '            RowPage += 1
        '        End If
        '    End If

        'Next
        
        Return True
    End Function

    Private Function GetCustomGridCon(ByVal strAERMODOUT As String(), ByVal Ynum As Integer, ByVal Xnum As Integer, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal strGrid As String, ByVal version As String) As ResultCon(,)
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        Dim AGridData(Ynum - 1, Xnum - 1) As ResultCon
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3 '
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") And strLineLine4.Contains(strGrid.ToUpper) Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 7 '
                    '开始读取网格数据
                    Dim strDate As String
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        For j As Integer = ColPage * 5 To ColPage * 5 + 4
                            If strDate.Substring(nVer + 11 + nCol * 24, 13) = "*************" Then
                                MsgBox("您输入的污染物排放源强可能过大，已经超出最大范围。")
                                Return Nothing
                            End If
                            AGridData(i, j).con = strDate.Substring(nVer + 11 + nCol * 24, 13)
                            AGridData(i, j).dateD = strDate.Substring(nVer + 26 + nCol * 24, 8)

                            If j >= Xnum - 1 Then
                                Exit For
                            End If
                            nCol += 1
                        Next
                        nCol = 0
                        If i >= Ynum - 1 Then
                            ColPage += 1
                            RowPage = -1
                            Exit For
                        End If
                    Next
                    RowPage += 1
                End If
            End If

        Next
        Return AGridData
    End Function

    ''' <summary>
    ''' 获取网格的沉积
    ''' </summary>
    ''' <param name="strAERMODOUT"></param>
    ''' <param name="Ynum"></param>
    ''' <param name="Xnum"></param>
    ''' <param name="IsDep"></param>
    ''' <param name="strAerageTime"></param>
    ''' <param name="strHIGHEST"></param>
    ''' <param name="strGroup"></param>
    ''' <param name="GroupSourceCount"></param>
    ''' <param name="strGrid"></param>
    ''' <param name="strDep"></param>
    ''' <param name="version"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetCustomGridDep(ByVal strAERMODOUT As String(), ByVal Ynum As Integer, ByVal Xnum As Integer, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal strGrid As String, ByVal strDep As String, ByVal version As String) As ResultDEPOS(,)
        Dim nVer As Integer = 0
        If version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then
            nVer = 1
        End If
        Dim AGridData(Ynum - 1, Xnum - 1) As ResultDEPOS
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains(strDep) And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3 '
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") And strLineLine4.Contains(strGrid.ToUpper) Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 7 '
                    '开始读取网格数据
                    Dim strDate As String
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        For j As Integer = ColPage * 5 To ColPage * 5 + 4
                            If strDate.Substring(nVer + 11 + nCol * 24, 13) = "*************" Then
                                MsgBox("您输入的污染物排放源强可能过大，已经超出最大范围。")
                                Return Nothing
                            End If
                            AGridData(i, j).DEPOS = strDate.Substring(nVer + 11 + nCol * 24, 13)
                            AGridData(i, j).dateD = strDate.Substring(nVer + 26 + nCol * 24, 8)

                            If j >= Xnum - 1 Then
                                Exit For
                            End If
                            nCol += 1
                        Next
                        nCol = 0
                        If i >= Ynum - 1 Then
                            ColPage += 1
                            RowPage = -1
                            Exit For
                        End If
                    Next
                    RowPage += 1
                End If
            End If

        Next
        Return AGridData
    End Function

    ''' <summary>
    ''' 获取网格点前n大给定短期间的浓度分布
    ''' </summary>
    ''' <param name="strAERMODOUT">输出文件名内容的一维数组</param>
    ''' <param name="Receptor">接受点</param>
    ''' <param name="IsDep">沉降</param>
    ''' <param name="strHIGHEST">第几大</param>
    ''' <param name="strAerageTime">平均时间</param>
    ''' <param name="strGroup">组</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetGridMaxDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then
            nVer = 0
        End If
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            Try
                strLine = strAERMODOUT(nAllString) '读取一行
                If strLine.Contains("SUMMARY OF") And strLine.Contains(strAerageTime) And strLine.Contains("RESULTS") Then
                    '开始计数
                    nAllString += 5

                    Dim strLineLine4 As String = strAERMODOUT(nAllString)
                    If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
                        nAllString += 1
                        strLineLine4 = strAERMODOUT(nAllString)
                        If strLineLine4.Contains("CONC") Then '浓度。用ON来区分指定时区的浓度和全时段的浓度
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    Dim m_GridMaxCon As ResultCon
                                    m_GridMaxCon.con = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxCon.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxCon.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxCon.y = strDate.Substring(nVer + 78, 11)
                                    Me.m_GridCon.GridMaxCon = m_GridMaxCon
                                    Exit Try
                                End If
                            Next
                        ElseIf strLineLine4.Contains("TOTAL DEPO") Then '总沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    Dim m_GridMaxDepos As ResultDEPOS
                                    m_GridMaxDEPOS.DEPOS = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxDEPOS.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxDEPOS.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxDepos.y = strDate.Substring(nVer + 78, 11)
                                    Me.m_GridDEPOS.GridMaxDEPOS = m_GridMaxDepos
                                    Exit Try
                                End If
                            Next
                        ElseIf strLineLine4.Contains("DRY DEPO") Then '干沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    Dim m_GridMaxDdep As ResultDEPOS
                                    m_GridMaxDdep.DEPOS = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxDDEP.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxDDEP.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxDdep.y = strDate.Substring(nVer + 78, 11)
                                    Me.m_GridDDEP.GridMaxDEPOS = m_GridMaxDdep
                                    Exit Try
                                End If
                            Next

                        ElseIf strLineLine4.Contains("WET DEPO") Then '湿沉降
                            nAllString += 2
                            '开始读取网格数据
                            Dim strDate As String
                            For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                                nAllString += 1
                                strDate = strAERMODOUT(nAllString)
                                If strDate.Contains("*** RECEPTOR TYPES") Then
                                    Exit Try
                                End If
                                If strDate.Contains(strGroup.ToUpper) = True And strDate.Contains("ON") Then
                                    Dim m_GridMaxWDEP As ResultDEPOS
                                    m_GridMaxWDEP.DEPOS = strDate.Substring(nVer + 33, 13)
                                    m_GridMaxWDEP.dateD = strDate.Substring(nVer + 51, 8)
                                    m_GridMaxWDEP.x = strDate.Substring(nVer + 65, 11)
                                    m_GridMaxWDEP.y = strDate.Substring(nVer + 78, 11)
                                    Me.m_GridWDEP.GridMaxDEPOS = m_GridMaxWDEP
                                    Exit Try
                                End If
                            Next

                        End If
                    End If
                End If
            Catch ex As Exception

            End Try

        Next
        Return True
    End Function
    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格和关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT内容数组</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetPeriodDate(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        '获取期间平均网格点浓度
        If GetGridPeriodDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, GroupSourceCount, Version) = False Then
            Return False
        End If
        '获取期间平均离散点浓度
        If GetDiscPeriodDateFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, GroupSourceCount, version) = False Then '浓度、沉积
            Return False
        End If
        '获取期间平均中网格点最大浓度
        If GetGridPeriodMaxDataFromAERMODOUT(strAERMODOUT, Receptor, IsDep, strGroup, version) = False Then
            Return False
        End If
        Return True
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <param name="GroupSourceCount">污染物组源中污染源的个数</param>
    ''' <remarks></remarks>
    Public Function GetGridPeriodDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        '主网格的浓度
        ReDim Me.m_GridCon.GridCon(Receptor.GridCart.Ynum - 1, Receptor.GridCart.Xnum - 1)
        Dim AGridCon(,) As ResultCon = GetCustomPeriodGridCon(strAERMODOUT, Receptor.GridCart.Ynum, Receptor.GridCart.Xnum, strGroup, GroupSourceCount, Receptor.GridCart.Netid, version)
        If AGridCon IsNot Nothing Then
            Me.m_GridCon.GridCon = AGridCon
            '根据网格数据求最大值和最小值
            Me.m_GridCon.CalMaxAndMinValue(Receptor.GridCart.Xnum, Receptor.GridCart.Ynum)
        End If
        ReDim Me.m_SubGridCon(Receptor.SubGridCart.Length - 1)
        For isub As Integer = 0 To Receptor.SubGridCart.Length - 1
            Dim BGridCon(,) As ResultCon = GetCustomPeriodGridCon(strAERMODOUT, Receptor.SubGridCart(isub).Ynum, Receptor.SubGridCart(isub).Xnum, strGroup, GroupSourceCount, Receptor.SubGridCart(isub).Netid, version)
            If BGridCon IsNot Nothing Then
                Me.m_SubGridCon(isub) = New GridCon
                Me.m_SubGridCon(isub).GridCon = BGridCon
                '根据网格数据求最大值和最小值
                Me.m_SubGridCon(isub).CalMaxAndMinValue(Receptor.SubGridCart(isub).Xnum, Receptor.SubGridCart(isub).Ynum)
            End If
        Next

        'ReDim Me.m_GridCon(Receptor.GridCart.Ynum - 1, Receptor.GridCart.Xnum - 1)
        'Dim strLine As String = "" '读取一行
        'Dim nCol As Integer = 0 '用于记列数
        'Dim RowPage As Integer = 0 '用于标记行的页数
        'Dim ColPage As Integer = 0 '用于标记列的页数
        'For nAllString As Integer = 0 To strAERMODOUT.Length - 1
        '    strLine = strAERMODOUT(nAllString) '读取一行
        '    If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
        '        '开始计数

        '        nAllString += 3
        '        If GroupSourceCount > 19 Then
        '            nAllString += 2
        '        ElseIf GroupSourceCount > 7 Then
        '            nAllString += 1
        '        End If
        '        Dim strLineLine4 As String = strAERMODOUT(nAllString)
        '        If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
        '            nAllString += 7
        '            '开始读取网格数据
        '            Dim strDate As String
        '            For i As Integer = RowPage * 40 To RowPage * 40 + 39
        '                nAllString += 1
        '                strDate = strAERMODOUT(nAllString)
        '                For j As Integer = ColPage * 9 To ColPage * 9 + 8
        '                    If strDate.Substring(14 + nCol * 13, 13) = "*************" Then
        '                        MessageBox.Show("您输入的污染物排放源强可能过大，已经超出最大范围。")
        '                        Return False
        '                    End If
        '                    Me.m_GridCon(i, j).con = strDate.Substring(14 + nCol * 13, 13)
        '                    If j >= Receptor.GridCart.Xnum - 1 Then
        '                        Exit For
        '                    End If
        '                    nCol += 1
        '                Next
        '                nCol = 0
        '                If i >= Receptor.GridCart.Ynum - 1 Then
        '                    ColPage += 1
        '                    RowPage = -1
        '                    Exit For
        '                End If
        '            Next
        '            RowPage += 1
        '        End If
        '    End If
        'Next


        
        Return True

    End Function
    ''' <summary>
    ''' 获取期间平均的浓度
    ''' </summary>
    ''' <param name="strAERMODOUT"></param>
    ''' <param name="Ynum"></param>
    ''' <param name="Xnum"></param>
    ''' <param name="strGroup"></param>
    ''' <param name="GroupSourceCount"></param>
    ''' <param name="strGrid"></param>
    ''' <param name="version"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function GetCustomPeriodGridCon(ByVal strAERMODOUT As String(), ByVal Ynum As Integer, ByVal Xnum As Integer, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal strGrid As String, ByVal version As String) As ResultCon(,)
        Dim nVer As Integer = 0
        If version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then
            nVer = 1
        End If
        Dim AGridCon(Ynum - 1, Xnum - 1) As ResultCon
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数

                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") And strLineLine4.Contains(strGrid.ToUpper) Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 7
                    '开始读取网格数据
                    Dim strDate As String
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        For j As Integer = ColPage * 9 To ColPage * 9 + 8
                            If strDate.Substring(nVer + 14 + nCol * 13, 13) = "*************" Then
                                MsgBox("您输入的污染物排放源强可能过大，已经超出最大范围。")
                                Return Nothing
                            End If
                            AGridCon(i, j).con = strDate.Substring(nVer + 14 + nCol * 13, 13)
                            If j >= Xnum - 1 Then
                                Exit For
                            End If
                            nCol += 1
                        Next
                        nCol = 0
                        If i >= Ynum - 1 Then
                            ColPage += 1
                            RowPage = -1
                            Exit For
                        End If
                    Next
                    RowPage += 1
                End If
            End If
        Next
        Return AGridCon
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均网格数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetGridPeriodMaxDataFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf version = "09292" Then '这个没有变化
            nVer = 0
        End If
        Dim strLine As String = "" '读取一行
        Dim nCol As Integer = 0 '用于记列数
        Dim RowPage As Integer = 0 '用于标记行的页数
        Dim ColPage As Integer = 0 '用于标记列的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("THE SUMMARY OF MAXIMUM PERIOD") Then
                '开始计数
                nAllString += 5

                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("NETWORK") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 1
                    strLineLine4 = strAERMODOUT(nAllString)
                    If strLineLine4.Contains("CONC") Then '浓度
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = GRIDCART") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    Dim m_GridMaxCon As New ResultCon
                                    m_GridMaxCon.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxCon.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxCon.con = strDate.Substring(nVer + 30, 13)
                                    Me.m_GridCon.GridMaxCon = m_GridMaxCon
                                    Exit For
                                End If
                            End If
                        Next
                    ElseIf strLineLine4.Contains("TOTAL DEPO") Then '总沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = GRIDCART") Then
                                Exit For
                            Else

                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    Dim m_GridMaxDEPOS As New ResultDEPOS
                                    m_GridMaxDEPOS.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxDEPOS.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxDEPOS.DEPOS = strDate.Substring(nVer + 30, 13)
                                    Me.m_GridDEPOS.GridMaxDEPOS = m_GridMaxDEPOS
                                    Exit For
                                End If
                            End If
                        Next
                    ElseIf strLineLine4.Contains("DRY DEPO") Then '干沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = GRIDCART") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    Dim m_GridMaxDDEP As New ResultDEPOS
                                    m_GridMaxDDEP.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxDDEP.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxDDEP.DEPOS = strDate.Substring(nVer + 30, 13)
                                    Me.m_GridDDEP.GridMaxDEPOS = m_GridMaxDDEP
                                    Exit For
                                End If
                            End If
                        Next

                    ElseIf strLineLine4.Contains("WET DEPO") Then '湿沉降
                        nAllString += 2
                        '开始读取网格数据
                        Dim strDate As String
                        For i As Integer = 0 To strAERMODOUT.Length - 10 - nAllString
                            nAllString += 1
                            strDate = strAERMODOUT(nAllString)
                            If strDate.Contains("*** RECEPTOR TYPES:  GC = GRIDCART") Then
                                Exit For
                            Else
                                If strDate.Contains(strGroup.ToUpper) = True Then
                                    Dim m_GridMaxWDEP As New ResultDEPOS
                                    m_GridMaxWDEP.x = strDate.Substring(nVer + 48, 11)
                                    m_GridMaxWDEP.y = strDate.Substring(nVer + 61, 11)
                                    m_GridMaxWDEP.DEPOS = strDate.Substring(nVer + 30, 13)
                                    Me.m_GridWDEP.GridMaxDEPOS = m_GridMaxWDEP
                                    Exit For
                                End If
                            End If
                        Next

                    End If
                End If
            End If
        Next
        Return True
    End Function

    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的期间平均关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件名及路径</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetDiscPeriodDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        ReDim Preserve Me.m_DiscCon(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDEPOS(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDDEP(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscWDEP(Receptor.DiscCarts.Length - 1)
        Dim strLine As String = "" '读取一行
        Dim RowPage As Integer = 0 '用于标记行的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1
            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains("PERIOD") And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscCon(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscCon(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscCon(i * 2).con = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscCon(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscCon(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscCon(i * 2 + 1).con = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains("PERIOD") And strLine.Contains("TOTAL DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDEPOS(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscDEPOS(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscDEPOS(i * 2).DEPOS = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDEPOS(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).DEPOS = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            ElseIf strLine.Contains("PERIOD") And strLine.Contains("DRY DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDDEP(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscDDEP(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscDDEP(i * 2).DEPOS = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDDEP(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscDDEP(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscDDEP(i * 2 + 1).DEPOS = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains("PERIOD") And strLine.Contains("WET DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscWDEP(i * 2).x = strDate.Substring(nVer + 4, 13)
                        Me.m_DiscWDEP(i * 2).y = strDate.Substring(nVer + 18, 13)
                        Me.m_DiscWDEP(i * 2).DEPOS = strDate.Substring(nVer + 33, 13)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscWDEP(i * 2 + 1).x = strDate.Substring(nVer + 64, 13)
                            Me.m_DiscWDEP(i * 2 + 1).y = strDate.Substring(nVer + 78, 13)
                            Me.m_DiscWDEP(i * 2 + 1).DEPOS = strDate.Substring(nVer + 93, 13)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            End If
        Next
        Return True
    End Function


    ''' <summary>
    ''' 从AERMOD.OUT文件中获取相应的平均时间内的关心点数据
    ''' </summary>
    ''' <param name="strAERMODOUT">AERMOD.OUT文件内容</param>
    ''' <param name="Receptor">网格和关心点对象</param>
    ''' <param name="IsDep">是否考虑沉降</param>
    ''' <param name="strGroup">污染物组源</param>
    ''' <remarks></remarks>
    Public Function GetDiscDateFromAERMODOUT(ByVal strAERMODOUT As String(), ByVal Receptor As Receptor, ByVal IsDep As Boolean, ByVal strAerageTime As String, ByVal strHIGHEST As String, ByVal strGroup As String, ByVal GroupSourceCount As Integer, ByVal version As String) As Boolean
        Dim nVer As Integer = 0
        If Version = "07026" Then
            nVer = 0
        ElseIf Version = "09292" Then
            nVer = 1
        End If
        ReDim Preserve Me.m_DiscCon(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDEPOS(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscDDEP(Receptor.DiscCarts.Length - 1)
        ReDim Preserve Me.m_DiscWDEP(Receptor.DiscCarts.Length - 1)
        Dim strLine As String = "" '读取一行
        Dim RowPage As Integer = 0 '用于标记行的页数
        For nAllString As Integer = 0 To strAERMODOUT.Length - 1

            strLine = strAERMODOUT(nAllString) '读取一行
            If strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("CONCENTRATION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscCon(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscCon(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscCon(i * 2).con = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscCon(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscCon(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscCon(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscCon(i * 2 + 1).con = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscCon(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("TOTAL DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDEPOS(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscDEPOS(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscDEPOS(i * 2).DEPOS = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscDEPOS(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDEPOS(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).DEPOS = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscDEPOS(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("DRY DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscDDEP(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscDDEP(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscDDEP(i * 2).DEPOS = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscDDEP(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscDDEP(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscDDEP(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscDDEP(i * 2 + 1).DEPOS = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscDDEP(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If
            ElseIf strLine.Contains(strHIGHEST) And strLine.Contains(strAerageTime) And strLine.Contains("WET DEPOSITION") And strLine.Contains(strGroup.ToUpper) Then
                '开始计数
                nAllString += 3
                If GroupSourceCount > 19 Then
                    nAllString += 2
                ElseIf GroupSourceCount > 7 Then
                    nAllString += 1
                End If
                Dim strLineLine4 As String = strAERMODOUT(nAllString)
                If strLineLine4.Contains("DISCRETE") Then '用于判断是不是网格点。如果是按网格点读取数据
                    nAllString += 5
                    '开始读取网格数据
                    Dim strDate As String
                    Dim IsEnd As Boolean = False
                    For i As Integer = RowPage * 40 To RowPage * 40 + 39
                        nAllString += 1
                        strDate = strAERMODOUT(nAllString)
                        Me.m_DiscWDEP(i * 2).x = strDate.Substring(nVer + 3, 13)
                        Me.m_DiscWDEP(i * 2).y = strDate.Substring(nVer + 16, 13)
                        Me.m_DiscWDEP(i * 2).DEPOS = strDate.Substring(nVer + 31, 13)
                        Me.m_DiscWDEP(i * 2).dateD = strDate.Substring(nVer + 47, 8)
                        If (i + 1) * 2 <= Receptor.DiscCarts.Length Then
                            Me.m_DiscWDEP(i * 2 + 1).x = strDate.Substring(nVer + 68, 13)
                            Me.m_DiscWDEP(i * 2 + 1).y = strDate.Substring(nVer + 81, 13)
                            Me.m_DiscWDEP(i * 2 + 1).DEPOS = strDate.Substring(nVer + 96, 13)
                            Me.m_DiscWDEP(i * 2 + 1).dateD = strDate.Substring(nVer + 112, 8)
                        End If
                        If (i + 1) * 2 >= Receptor.DiscCarts.Length Then
                            IsEnd = True
                            RowPage = 0
                            Exit For
                        End If
                    Next
                    If IsEnd = False Then
                        RowPage += 1
                    End If
                End If

            End If
        Next
        Return True
    End Function
End Class


